package com.nut.spp.api.client;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nut.spp.api.req.GoodsQueryReq;
import com.nut.spp.common.Result;
import com.nut.spp.entity.Goods;
import com.nut.spp.service.GoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/client/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @GetMapping("/list")
    public Result<IPage<Goods>> listPage(GoodsQueryReq req) {
        return goodsService.listPage(req);
    }

    @GetMapping(value = "/{id}")
    public Result<Goods> detail(@PathVariable Integer id) {
        return goodsService.getById(id);
    }

}